package per.xue.carid_booking.dto.respondDTO;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.format.annotation.DateTimeFormat;
import per.xue.carid_booking.entity.Car;
import per.xue.carid_booking.entity.Station;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

/**
 * @auther
 * @ TO DO
 * @creatTime 2021/5/23 19:48
 **/

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CarRespondDTO {

    /**
     * 车次id
     */
    private String carId;

    /**
     * 发车时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date time;

    /**
     * 初始站id
     */
    private Integer startStationId;

    /**
     * 初始站名字
     */
    private  String startStationName;

    /**
     * 终点站id
     */
    private Integer endStationId;

    /**
     * 终点站名字
     */
    private  String endStationName;

    /**
     * 价格
     */
    private Double price;

    /**
     * 剩余量
     */
    private Integer surplusNum;

    /**
     * 状态
     */
    private String stats;

    public CarRespondDTO(Car car, String startStationName, String endStationName) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        PropertyUtils.copyProperties(this, car);
        this.startStationName = startStationName;
        this.endStationName = endStationName;
    }

}
